package main

import (
	"fmt"
)

type Integer int

// func (a Integer) Add(b Integer) Integer {
// 	return a + b
// }

func (a *Integer) Add(b Integer) Integer {
	return *a + b
}

type Bird interface {
	Fly() string
}

type Plane struct {
	Name string
}

func (plane Plane) Fly() string {
	fmt.Println("plane fly")
	return "plane fly"
}

// func (plane *Plane) Fly() string {
// 	fmt.Println("plane fly")
// 	return "plane fly"
// }

func CheckFly(bird Bird) {
	plane_p, b := bird.(*Plane)
	if b {
		fmt.Println("plane pointer convert success, is ", plane_p)
	}

	plane, b := bird.(Plane)
	if b {
		fmt.Println("plane conver success, is ", plane)
	}
}

type People interface {
	Show()
}
type Student struct{}

func (stu *Student) Show() {
}

func live() People {
	var stu *Student
	return stu
}

func Self() *Student {
	var stu *Student
	return stu
}

type Empty interface {
}

func empty() Empty {
	var stu *Student
	return stu
}

func main() {

	var a Integer = 1
	var b Integer = 2
	var i interface{} = &a
	sum := i.(*Integer).Add(b)
	fmt.Println(sum)

	var a2 Integer = 1
	var b2 Integer = 2

	sum2 := a2.Add(b2)
	fmt.Println(sum2)

	plane := Plane{Name: "plane"}
	plane.Fly()

	plane_p := &Plane{Name: "plane_p"}
	plane_p.Fly()

	CheckFly(plane)
	CheckFly(plane_p)

	if live() == nil {
		fmt.Println("AAAAAAA")
	} else {
		fmt.Println("BBBBBBB")
	}

	if Self() == nil {
		fmt.Println("AAAAAAA")
	} else {
		fmt.Println("BBBBBBB")
	}

	if empty() == nil {
		fmt.Println("AAAAAAA")
	} else {
		fmt.Println("BBBBBBB")
	}
}
